package com.ylzinfo.ms.factory.baseHandle;

import com.ylzinfo.ms.factory.AbstoryEnAndDeFactory;
import com.ylzinfo.ms.utils.AES.AesUtils;
import org.springframework.util.StringUtils;

/**
 * @Description: aes基础类的实现
 * @Product: IntelliJ IDEA
 * @Author Rogchen rogchen128@gmail.com
 * @Created Date: 2019/3/29 10:14
 **/
public class AESBaseHandle extends AbstoryEnAndDeFactory {

    @Override
    public String encoderBase64(String data, String key) {
        if (!StringUtils.isEmpty(key)) {
            String param = AesUtils.encodeToBase64(data, key);
            return param;
        }
        throw new RuntimeException("加密密钥不能为空！");
    }

    @Override
    public String decoderBase64(String data, String key) {
        if (!StringUtils.isEmpty(key)) {
            String param = AesUtils.decryptBase64ToString(data, key);
            return param;
        }
        throw new RuntimeException("解密密钥不能为空！");
    }


}
